﻿
using RabbitMQ.Client;
namespace Athena.RabbitMQ.Implementations
{


    public class RabbitMQModel : IRabbitMQModel
    {
        public IModel Model {
            get;
        }

        /// <summary>
        /// exchange名称
        /// </summary>
        public string Name {
            get; set;
        }

        /// <summary>
        /// exchange类型 目前支持direct topic fanout
        /// </summary>
        public string Type {
            get; set;
        }

        /// <summary>
        /// 是否持久化
        /// </summary>
        public bool Durable {
            get; set;
        }

        /// <summary>
        /// 是否自主删除
        /// </summary>
        public bool AutoDelete {
            get; set;
        }

        public RabbitMQModel(IModel model)
        {
            Model = model;
            Type = ExchangeType.Direct;
            Durable = false;
            AutoDelete = false;
        }

        public void Declare(IModel model)
        {
            model.ExchangeDeclare(Name, Type.ToString(), Durable, AutoDelete, null);
            model.QueueDeclare();
        }
    }
}
